package com.rabbitmq.rabbitmqqos.controller;

import com.rabbitmq.rabbitmqqos.constant.Constants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/qos")
@RestController
public class RabbitMQController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/quorum")
    public String quorum() {

        String message = "quorum ...";

        rabbitTemplate.convertAndSend("", Constants.QUORUM_QUEUE, message);

        return "消息发送成功";
    }

    @RequestMapping("/haproxy")
    public String haproxy() {

        String message = "haproxy ...";

        rabbitTemplate.convertAndSend("", Constants.HAPROXY_QUEUE, message);

        return "消息发送成功";
    }
}
